package edu.wuster.blog.mapper;

import edu.wuster.blog.entity.Message;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;


@Mapper
public interface MessageMapper {

    @Select("select * from message where user_id= #{userId} and is_delete = 0")
    List<Message> selectByUserId(Integer userId);

    @Update("update  message set is_delete = 1 where id = #{id}")
    void deleteById(Integer id);

    @Insert("insert into message(user_id, text, create_time) values (#{userId},#{text},#{createTime})")
    void addMessage(Message message);

    @Select("select * from message where id = #{id} and is_delete = 0")
    Message selectById(Integer id);
}
